/***************************************************************
*  NAME:    digest
*	    
*  SYNOPSIS:   digesta api
*    	    
*  DESCRIPTION:
*     	    
*  HISTORY:
*      	         pascal - Jan 22, 2012:  Created.
*
***************************************************************/
#ifndef _DIGEST_H__
#define _DIGEST_H__

#define DIGEST_BLOCK_SIZE  64

typedef enum { digest_none, digest_MD5, digest_SHA1, digest_SHA256 } digest_type_t;

typedef struct digest_ctx_s
{
	digest_type_t dtype;
	unsigned int *hash;
	int hash_len;
	unsigned int input_len;

        void (*new_ctx) (struct digest_ctx_s *);
	void (*block_operate) (const unsigned char *input, unsigned int hash[]);
	void (*block_finalize) (unsigned char *block, int length);

	// temp storage for 'unprocessed data'
	unsigned char block [DIGEST_BLOCK_SIZE];
	int block_len;  
}  digest_ctx;



void update_digest(digest_ctx *context, const unsigned char *input, int input_len);
void finalize_digest(digest_ctx *context);
void new_md5_digest(digest_ctx * context);
void new_digest(digest_ctx * context);
void print_digest(char * name, digest_ctx * context);

#endif /* DIGEST */
